<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
request.setCharacterEncoding("UTF-8");
String htmlData = request.getParameter("content1") != null ? request.getParameter("content1") : "";
%>
<!doctype html>
<html>
<head>
	<meta charset="utf-8" />
	<title>KindEditor JSP</title>
	<link rel="stylesheet" href="../resource/css/default.css" />
	<link rel="stylesheet" href="../resource/css/prettify.css" />
	<link href="../resources/css/bootstrap.min.css" rel="stylesheet"
	media="screen">
	<script charset="utf-8" src="../resources/js/kindeditor.js"></script>
	<script charset="utf-8" src="../resources/js/zh_CN.js"></script>
	<script charset="utf-8" src="../resources/js/prettify.js"></script>
<link href="../resources/css/style.css" rel="stylesheet">
<script src="../resources/js/jquery-1.9.2.min.js"></script>
	<script src="../resources/js/bootstrap.min.js"></script>
	<script src="../resources/js/js.js"></script>
	<script>
		KindEditor.ready(function(K) {
			var editor1 = K.create('textarea[name="content1"]', {
				cssPath : '../plugins/code/prettify.css',
				uploadJson : '../jsp/upload_json.jsp',
				fileManagerJson : '../jsp/file_manager_json.jsp',
				allowFileManager : true,
				afterCreate : function() {
					var self = this;
					K.ctrl(document, 13, function() {
						self.sync();
						document.forms['example'].submit();
					});
					K.ctrl(self.edit.doc, 13, function() {
						self.sync();
						document.forms['example'].submit();
					});
				}
			});
			prettyPrint();
		});
		function sendValue() {
			
			var goods_Id = $("#goods_Id").val();
			var adver_Seq = $("#adver_Seq").val();

			
			if ($.trim(goods_Id) == null || $.trim(goods_Id) == "") {

				alert("商铺名称不能为空");
				return;

			}
			if ($.trim(adver_Seq) == null || $.trim(adver_Seq) == "") {

				alert("图片顺序不能为空");
				return;
			}
			$('#form1').submit();
		}

		function pageHref(page, totalPage, pageSize) {

			$.ajax({
				url : "${webRoot}/web/manager/ad/page.do?page=" + page
						+ "&pageSize=" + pageSize + "&totalPage=" + totalPage,
				type : "post",
				cache : "false",
				error : function() {
					alert("系统繁忙，请稍后再试！");
				},
				success : function(msg) {
					$("#div").html(msg);
				}
			});
		}

		function deleteHref(id) {

			$.ajax({
				url : "${webRoot}/web/manager/ad/delete.do?adver_Id=" + id,
				type : "post",
				cache : "false",
				error : function() {
					alert("系统繁忙，请稍后再试！");
				},
				success : function(msg) {
					$("#div").html(msg);
				}
			});
		}
	</script>
</head>
<body class="main">
	<%=htmlData%>
	<ul class="breadcrumb">
		<li><span id="test">您当前的位置：</span><a href="#">首页</a> <span
			class="divider">>></span></li>
		<li class="active">${ad}</li>
	</ul>
	
	<form class="form-horizontal" method="post"
		enctype="multipart/form-data"
		action="${webRoot}/web/manager/ad/modify.do" id="form1">
		<input type="hidden" id="adver_Id" name="adver_Id" value="${adverEntity.adver_Id}"/>
		<div class="control-group">
			<label class="control-label" for="file">图片上传</label>
			<div class="controls">
				<input type="file" id="file" name="file">
				<div class="preview">
					<img src="${adverEntity.adver_Image}">
				</div>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="adver_Position">类型</label>
			<div class="controls">
				<select class="select" id="adver_Position" name="adver_Position">
					<#if adverEntity.adver_Position=='s'>
					<option value="s" selected="selected">开机启动页</option>
					<option value="a" >首页</option>
					</#if>
					<#if adverEntity.adver_Position=='a'>
					<option value="s" >开机启动页</option>
					<option value="a" selected="selected">首页</option>
					</#if>
				</select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="goods_Id">商铺名称</label>
			<div class="controls">
				<select id="goods_Id" name="goods_Id">
					<#list listGoods as goodsEntity>
				        <#if goodsEntity.goods_id==adverEntity.goods_Id>
				         <option value="${goodsEntity.goods_id}" selected="selected" >${goodsEntity.goods_Name}</option>
				         <#else>
				         <option value="${goodsEntity.goods_id}" >${goodsEntity.goods_Name}</option>
				         </#if>
				 	</#list>
				</select>
				</select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="adver_Desc">广告描述</label>
			<div class="controls">
				<input type="text" id="adver_Desc" name="adver_Desc" value="${adverEntity.adver_Desc}"
					placeholder="图片描述">
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="adver_Seq">图片顺序</label>
			<div class="controls">
				<input type="number" id="adver_Seq" name="adver_Seq" value="${adverEntity.adver_Seq}"
					placeholder="图片顺序">
			</div>
		</div>
		<div class="control-group">
			<div class="controls">
				<textarea name="content1" cols="100" rows="8" style="width:700px;height:200px;visibility:hidden;"><%=htmlspecialchars(htmlData)%></textarea>
			</div>
		</div>
		<div class="control-group">
			<div class="controls">
				<button type="button" class="btn" onclick="sendValue()">确认修改</button>
			</div>
		</div>
	</form>
</body>
</html>
<%!
private String htmlspecialchars(String str) {
	str = str.replaceAll("&", "&amp;");
	str = str.replaceAll("<", "&lt;");
	str = str.replaceAll(">", "&gt;");
	str = str.replaceAll("\"", "&quot;");
	return str;
}
%>